<template>
  <view>
    <view class="benefit-guide-widget" @click="dialogVisible = true">
      <view class="guide-nav-box">
        {{ invitePrice }}
      </view>
    </view>
    <el-dialog v-model="dialogVisible" title="Tips" width="700" center :before-close="handleClose">
      <template #header>
        <div class="title-box">
          <span class="txt title">推广赚</span> 
          <span class="txt money-unit">¥</span>
          <span class="txt">{{ invitePrice }}</span>
        </div>
      </template>
      <div class="sub-title">
        <span class="txt title">邀请好友成功购买图片，每单最高得</span> 
        <span class="txt money-unit">¥</span>
        <span class="txt">{{ invitePrice }}现金奖励</span>
      </div>
      <div class="desc">
        <div class="txt title">一次绑定永久有效，每次交易都有收入;二级分佣20%，三级分佣5%，可提现</div> 
        <!-- <div class="txt title">二级分佣20%，三级分佣5%，可提现</div> -->
      </div>
      <div class="link wow fadeInUp" style="visibility: visible; animation-name: fadeInUp;">
        <span>推荐链接</span>
        <p id="url">{{ url }}</p>
        <div class="copy" @click="copy"></div>
      </div>
      <template #footer>
        <span class="dialog-footer">
          <el-button @click="dialogVisible = false">关闭</el-button>
        </span>
      </template>
    </el-dialog>
  </view>
</template>

<script setup>
  import {
    ref,
    computed
  } from 'vue'
  let userInfo = uni.vk.getVuex('$user.userInfo')
  let url = `https://haimi-ai-1302621554.cos.ap-nanjing.myqcloud.com/AI/index.html#/?t=${userInfo.my_invite_code}`
  
  const copy = () => {
     uni.setClipboardData({
        data: url,//要被复制的内容
        success:()=>{//复制成功的回调函数
          uni.showToast({//提示
            title:'复制成功'
          })
        }
      });
  }
  
  let dialogVisible = ref(false)
  const prop = defineProps({
    price: {
      type: Number
    }
  })
  const invitePrice = computed(() => {
    return prop.price ? uni.vk.pubfn.priceFilter(prop.price * 100 * 0.2) : 0
  })
</script>

<style scoped lang="scss">
  .benefit-guide-widget {
    position: absolute;
    right: 0;
    top: 20px;
    cursor: pointer;
    .guide-nav-box {
      font-family: alibaba puhui font;
      display: flex;
      box-sizing: border-box;
      height: 32px;
      line-height: 30px;
      background-position: 0 0;
      background-image: url(//lf3-cdn-tos.bytescm.com/obj/static/xitu_juejin_web/img/reward_bg_web.3c9ff92.png);
      background-repeat: no-repeat;
      background-size: cover;
      font-weight: 700;
      font-size: 15px;
      padding: 0 8px 0 85px;
      color: #fff;
      text-shadow: 0 1px 1px rgba(46, 53, 213, .25);
      white-space: nowrap;
    }
  }
  .title-box{
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--ui-BG-Main);
    .txt{
      font-weight: 600;
      font-size: 20px;
    }
    
  }
  .sub-title {
    height: 28px;
    font-size: 16px;
    color: #666;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    margin-bottom: 10px;
  }
  .desc {
    font-size: 14px;
    text-align: center;
    margin-top: 10px;
    color: #999;
  }
  .money-unit {
    margin-left:3px;
      margin-right: 3px;
      font-size: 16px;
      margin-bottom: -3px;
  }
  .link {
      margin: 50px 0 20px;
      display: flex;
      font-size: 14px;
      color: #53565d;
      span {
          width: 86px;
          height: 37px;
          background: #fff;
          border: 1px solid #e5e7eb;
          border-radius: 5px 0 0 5px;
          display: flex;
          align-items: center;
          justify-content: center;
      }
      p {
          height: 37px;
          display: flex;
          align-items: center;
          justify-content: center;
          padding-left: 14px;
          padding-right: 40px;
          border-top: 1px solid #e5e7eb;
          border-bottom: 1px solid #e5e7eb;
      }
      .copy {
          cursor: pointer;
          width: 51px;
          height: 37px;
          background: #fff url('../../static/copy.png') no-repeat center center/20px auto;
          border: 1px solid #e5e7eb;
          border-radius: 0 5px 5px 0;
      }
  }
</style>